 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 <link rel="stylesheet" href="model.css" />
  <?php include("head.php"); ?>
 <?php include("entete.php"); ?>
   <?php include("menu.php"); ?>
<?php


//connection au serveur:
try{
  $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
  $bdd = new PDO('mysql:host='.DB_SERVER.';dbname='.DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $pdo_options);
  
  /*  $sql ='SELECT * FROM EVENEMENT, DATES, AGENDA, ASSOCIATION, ORGANISATION 
   WHERE EVENEMENT.ID_EVENT=ORGANISATION.ID_EVENT 
   AND ORGANISATION.ID_ASSOC=ASSOCIATION.ID_ASSOC 
   AND AGENDA.ID_EVENT = EVENEMENT.ID_EVENT 
   AND AGENDA.ID_DATES=DATES.ID_DATES 
   ORDER BY ASSOCIATION.NOM_ASSOC, DATES.DATE_DEBUT';*/
  
  $sql='SELECT NOM_ASSOC, ID_ASSOC FROM ASSOCIATION ORDER BY NOM_ASSOC';
  $reponse = $bdd->query($sql);
  
  
  //affichage des données:
  while( $donnees = $reponse->fetch() )
    {
      echo(
           "<div align=\"center\">"
           .$donnees['NOM_ASSOC']."</div>");
      
      $id_assoc=$donnees['ID_ASSOC'];
      
      $sql ='SELECT * FROM EVENEMENT, DATES, AGENDA, ORGANISATION 
 WHERE EVENEMENT.ID_EVENT=ORGANISATION.ID_EVENT 
AND ORGANISATION.ID_ASSOC='.$id_assoc.' 
AND AGENDA.ID_EVENT = EVENEMENT.ID_EVENT 
AND AGENDA.ID_DATES=DATES.ID_DATES 
ORDER BY DATES.DATE_DEBUT';
      
      $reponse2=$bdd->query($sql);
      
      while( $donnees2 = $reponse2->fetch() ){
	
	echo(
	     "<div align=\"center\">"
	     .$donnees2['NOM_EVENT']."   ".$donnees2['DATE_DEBUT'].
	     " <a href=\"print_evt.php?idAssociation=".$donnees['ID_ASSOC']."&idEvenement=".$donnees2['ID_EVENT']."\">afficher</a> 
<a href=\"modif1_evt.php?idEvenement=".$donnees2['ID_EVENT']."\">modifier</a>  <a href=\"del_evt.php?idEvenement=".$donnees2['ID_EVENT']."&nomEvenement=".$donnees2['NOM_EVENT']."\">supprimer</a></div><br />"
	     ) ;
	
      }
      $reponse2->closeCursor();
      
    }
  $reponse->closeCursor();
}
catch (Exception $e)
{
  die('Erreur : ' . $e->getMessage());
} 
?>
 <?php include("pied_de_page.php"); ?>